#include <iostream>
#include <vector>
    using namespace std;

class Solution
{
public:
    // https://gitee.com/link?target=https%3A%2F%2Fleetcode.cn%2Fproblems%2Fsubstring-with-concatenation-of-all-words%2F
    vector<int> findSubstring(string s, vector<string> &words)
    {
        vector<int> v1;
        unordered_map<string, int> u1;
        for (auto &s : words)
        {
            u1[s]++;
        }
        int k = words.size();
        printf("k:%d", k);
        int n = words[0].size();
        int ssize = s.size();
        for (int i = 0; i < n; i++)
        {
            int count = 0;                 // count也需要重置
            unordered_map<string, int> u2; // 每次i++之后需要给u2重置一下
            for (int left = i, right = i; right < ssize; right += n)
            {
                string str(s, right, n);
                u2[str]++;
                if (u1.count(str) && u2[str] <= u1[str])
                    count++;
                if (right - left + 1 > k * n)
                {
                    string str1(s, left, n);
                    if (u1.count(str1) && u2[str1]-- <= u1[str1])
                        count--;
                    left += n;
                }
                if (count == k)
                    v1.push_back(left);
            }
        }
        return v1;
    }

    // https://gitee.com/link?target=https%3A%2F%2Fleetcode.cn%2Fproblems%2Fminimum-window-substring%2F
    string minWindow(string s, string t)
    {
        int hash1[128] = {0};
        int hash2[128] = {0};
        int k = t.size();
        int count = 0;
        for (auto &c : t)
        {
            hash1[c]++;
        }
        int begin = 0;
        int size = s.size() + 1; // 用size表示长度，begin表示起始位置
        for (int left = 0, right = 0; right < s.size(); right++)
        {
            if (hash2[s[right]]++ < hash1[s[right]])
                count++;
            while (count == k)
            {
                if (right - left + 1 < size)
                {
                    size = right - left + 1;
                    begin = left;
                }
                if (hash2[s[left]]-- == hash1[s[left]])
                    count--;
                left++;
            }
        }
        return size > s.size() ? "" : s.substr(begin, size);
    }

    //https://gitee.com/link?target=https%3A%2F%2Fwww.nowcoder.com%2Fpractice%2Facead2f4c28c401889915da98ecdc6bf%3FtpId%3D230%26tqId%3D2021480%26ru%3D%2Fexam%2Foj%26qru%3D%2Fta%2Fdynamic-programming%2Fquestion-ranking%26sourceUrl%3D%252Fexam%252Foj%253Fpage%253D1%2526tab%253D%2525E7%2525AE%252597%2525E6%2525B3%252595%2525E7%2525AF%252587%2526topicId%253D196
    int main()
    {
        int n, q;
        cin >> n >> q;
        vector<int> arr(n + 1, 0);
        vector<long> dp(n + 1, 0);
        for (int i = 1; i < n + 1; i++)
        {
            cin >> arr[i];
            dp[i] = arr[i] + dp[i - 1];
        }
        int l, r;
        while (scanf("%d%d", &l, &r) != EOF)
        {
            long sub = dp[r] - dp[l - 1];
            cout << sub << endl;
        }
        return 0;
    }
};